.\"
.\" Copyright (c) 2024 Alexander Ziaee. Ohio.
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.Dd March 21, 2025
.Dt NETWORKING 7
.Os
.Sh NAME
.Nm networking ,
.Nm wifi
.Nd quickstart guide to connecting to a network
.Sh DESCRIPTION
In the following examples, it is assumed that
we are connecting to Ethernet with the first interface found by the
.Xr ix 4
driver, and Wi-Fi with the first interface found by the
.Xr iwlwifi 4
driver, though your hardware will vary.
.Sh EXAMPLES
.Bl -tag -width 0n
.It Sy Example 1: Connecting to an Ethernet network with DHCP
.Pp
Ask for a DHCP lease on the first Intel 10Gb Ethernet interface:
.Bd -literal -offset 2n
.Ic # dhclient ix0
.Ed
.It Sy Example 2: Connecting to a cellular network with USB tethering
.Pp
Ask for a DHCP lease on the first USB tethering interface:
.Bd -literal -offset 2n
.Ic # dhclient ue0
.Ed
.It Sy Example 3: Connecting to a Wi-Fi network
.Pp
Identify your Wi-Fi hardware:
.Bd -literal -offset 2n
.Ic % sysctl net.wlan.devices
.Ed
.Pp
Create the
.Sy wlan0
interface with the first Intel Wi-Fi adapter:
.Bd -literal -offset 2n
.Ic # sysrc wlans_iwlwifi0="wlan0"
.Ed
.Pp
Set that interface to ask for a DHCP lease with
.Xr wpa_supplicant 8 :
.Bd -literal -offset 2n
.Ic # sysrc ifconfig_wlan0="WPA SYNCDHCP"
.Ed
.Pp
Enter the details of the Wi-Fi network:
.Bd -literal -offset 2n
.Ic # cd /etc/
.Ic # wpa_passphrase \(dqmyssid\(dq \(dqmypassphrase\(dq >> wpa_supplicant.conf
.Ed
.Pp
Restart the network interface daemon:
.Bd -literal -offset 2n
.Ic # service netif restart
.Ed
.It Sy Example 4: Scanning for Wi-Fi networks
.Bd -literal -offset 2n
.Ic % ifconfig wlan0 scan
.Ed
.It Sy Example 5: Airplane mode
.Bd -literal -offset 2n
.Ic # service netif stop
.Ed
.El
.Sh SEE ALSO
.Xr bsdconfig 8 ,
.Xr dhclient 8 ,
.Xr ifconfig 8 ,
.Xr wpa_passphrase 8
.Pp
The Advanced Networking chapter of the
.Fx
Handbook.
.Sh CAVEATS
Shell Special Characters in the
.Ar SSID
or
.Ar passphrase
will need to be escaped for
.Xr wpa_passphrase 8 ,
commonly using
.Ql \e ,
see the manual page for your shell for more details.
.Pp
Stopping the network interface service also stops internal networking.
